﻿using System.ComponentModel;
using System.Windows;
using Headsight.BPMN2WF.ConversionWizard;

namespace Headsight.BPMN2WF.GUI
{
    /// <summary>
    /// Interaction logic for WizardHost.xaml
    /// </summary>
    public partial class WizardHost : Window
    {
        private readonly BPMN2WFConverter _converterWizard;

        public string XamlFileContent { get; set; }
        public string XamlTempFilename { get; set; }

        public WizardHost()
        {
            InitializeComponent();

            _converterWizard = new BPMN2WFConverter();
            _converterWizard.PropertyChanged += _converterWizard_PropertyChanged;

            HostingGrid.Children.Add(_converterWizard);
        }

        private void _converterWizard_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "CloseMe")
            {
                XamlFileContent = _converterWizard.WorkflowXamlContent;
                XamlTempFilename = _converterWizard.WorkflowXamlTempFile;

                DialogResult = !string.IsNullOrEmpty(XamlFileContent);

                //Close();
            }
        }
    }
}
